#include "stdafx.h"  
//#define BOOST_TEST_MODULE ASTAR_TEST
#include <boost/test/unit_test.hpp> 
#include "test_context.h"
#include "test_case_context.h"

using namespace boost::unit_test;
using namespace test;

graph::global_data_t graph::global::global_;
boost::shared_ptr<test_context_t> test_context;

//____________________________________________________________________________//
//uses comparation of two rasterization algorithms and checks equality of their output
//we don't run this test, we prefere speed to precision
template<graph::details::delta d>
void raster_test_strict(test_case_context_t& context)
{  
   BOOST_TEST_MESSAGE("comparing rasterization with d = " << d);
   typedef std::set<graph::details::cell_id_t> rasterized_cells_t;
   rasterized_cells_t rasterized_cells;
   graph::details::cell_edge_iterator_pair_t fast_rast_d =
      test_context->get_fast_rasterized_graph().get_cells<d>();
   graph::details::cell_edge_iterator_pair_t vect_rast_d =
      test_context->get_vector_rasterized_graph().get_cells<d>();
   for(; fast_rast_d.first != fast_rast_d.second; ++fast_rast_d.first)
   {
      rasterized_cells.insert((*fast_rast_d.first).first);
   }
   for(; vect_rast_d.first != vect_rast_d.second; ++vect_rast_d.first)
   {
      graph::details::cell_id_t id = (*vect_rast_d.first).first;
      rasterized_cells_t::iterator foo = rasterized_cells.find(id);
      if (foo == rasterized_cells.end())
      {
         BOOST_(false && "rasterizations isn't equal");
      }
   }
   BOOST_REQUIRE(true);
}


void fake_test()
{
   BOOST_REQUIRE(true);
}
//____________________________________________________________________________//

//____________________________INIT TEST SUITE SECTION______________________________________//
//inits test suite
//rasterization code has some runtime checks, which enforced if defined RASTER_TEST symbol
//so simply initializing test suite gives us some testing in internal code of algorithms
test_suite* init_unit_test_suite( int argc, char* argv[] ) 
{
   if (argc < 1)
   {
      std::cerr << "Please supply file name with graph as first argument" << std::endl;
      exit(-1);
   }
   framework::master_test_suite().p_name.value = "rasterization test suite";
   test_context = boost::shared_ptr<test_context_t>(new test_context_t(argv[1]));
   boost::unit_test::unit_test_log.set_stream( test_context->get_test_log() );
   boost::unit_test::unit_test_log.set_threshold_level( boost::unit_test::log_messages );
   
   //don't run strict tests cause we don't use precision which gives equal results
   //framework::master_test_suite().
   //   add( BOOST_TEST_CASE( boost::bind(&raster_test_strict<graph::details::d1>, test_case_context_t()) ) );
   //
   //framework::master_test_suite().
   //   add( BOOST_TEST_CASE( boost::bind(&raster_test_strict<graph::details::d2>, test_case_context_t()) ) );
   //
   //framework::master_test_suite().
   //   add( BOOST_TEST_CASE( boost::bind(&raster_test_strict<graph::details::d4>, test_case_context_t()) ) );
   framework::master_test_suite().add(BOOST_TEST_CASE(&fake_test));
   return 0;
}

//____________________________________________________________________________//
